package com.group.mall.mapper;

import com.group.mall.domain.DTO.AddressDTO;
import com.group.mall.domain.POJO.Address;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AddressMapper {

    /*
    查询地址
     */
    @Select("select * from hmall.address where user_id = #{userId}")
    List<Address> getAddress(Long userId);
    /*
    删除地址
     */
    @Delete("delete  from hmall.address where id = #{id}")
    void deleteAddress(Long id);
    /*
    添加地址
     */
    @Insert("insert into hmall.address(user_id,mobile,street,contact)values (#{userId},#{mobile},#{street},#{contact})")
   void addAddress(AddressDTO addressDTO);
    /*
    删除全部地址
     */
    @Delete("delete  from hmall.address where user_id = #{userId}")
    void deleteAllAddress(Long userId);
    /*
    修改地址
     */
    @Update("update hmall.address set mobile = #{mobile} , street = #{street} ,contact = #{contact} where id = #{id}")
    void updateAddress(AddressDTO addressDTO);

}
